/***************************************************************************
 *  Copyright (C) 2009, 2010 by Axel Jaeger <axeljaeger@googlemail.com>    *
 *                                                                         *
 *  This file is part of Glowworm.                                         *
 *                                                                         *
 *  Glowworm is free software: you can redistribute it and/or modify       *
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation, version 3 of the License.                *
 *                                                                         *
 *  Glowworm is distributed in the hope that it will be useful,            *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with Glowworm.  If not, see <http://www.gnu.org/licenses/>.      *
 ***************************************************************************/

#ifndef HTTPRESPONSE_H
#define HTTPRESPONSE_H

#include <QString>


class QIODevice;

class HttpResponse
{
public:
    enum HttpStatusCode {
        HttpOK = 200,
        HttpForbidden = 403,
        HttpFileNotFound = 404,
        HttpInternalServerError = 500
    };

    HttpResponse();
    ~HttpResponse();

    QIODevice* outputDevice() const;
    void setOutputDevice(QIODevice* device);

    void setStatusCode(HttpStatusCode sc);
    HttpStatusCode statusCode() const;

    void setMimeType(const QString & mimeType);
    QString mimeType() const;

    int contentLength() const;
    void setContentLength(int nsize);

    void sendHeader();
    bool headerSent() const;

    static QString statusVerbose(HttpStatusCode sc);
private:
    QIODevice* m_outputDevice;
    HttpStatusCode m_statusCode;
    QString m_mimeType;
    int m_contentLength;
    bool m_headerSent;
};

#endif // HTTPRESPONSE_H
